import 'package:dynamic_forms/dynamic_forms.dart';
import 'package:meta/meta.dart';

class DyContainer extends FormElement {
  static const String childrenPropertyName = "children";

  List<FormElement> get children => properties[childrenPropertyName].value;
  Stream<List<FormElement>> get childrenChanged =>
      properties[childrenPropertyName].valueChanged;

  void fillContainer(
      {@required String id,
      @required ElementValue<FormElement> parent,
      @required ElementValue<bool> isVisible,
      @required ElementValue<List<FormElement>> children}) {
    fillFormElement(id: id, parent: parent, isVisible: isVisible);
    registerElementValue(childrenPropertyName, children);
  }

  @override
  FormElement getInstance() {
    return DyContainer();
  }
}
